//
//  AttachedLifeTableViewCell.m
//  BookSale
//
//  Created by dlios on 15-3-11.
//  Copyright (c) 2015年 dlios. All rights reserved.
//

#import "AttachedLifeTableViewCell.h"

@implementation AttachedLifeTableViewCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        
        
        //书架图片
        UIImageView *bookShelfImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 375, 40)];
        bookShelfImageView.image = [UIImage imageNamed:@"2.png"];
        [self.contentView addSubview:bookShelfImageView];
        [bookShelfImageView release];
        
        //白色底框
        UIView *whiteView = [[UIView alloc] initWithFrame:CGRectMake(12, 0, 353, 33)];
        whiteView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:whiteView];
        [whiteView release];
        
        //创建按钮
        //分享按钮
        //分享按钮
        self.shareButton = [UIButton buttonWithType: UIButtonTypeCustom];
        [self.shareButton setBackgroundImage:[UIImage imageNamed:@"btn_popup-data_n@2x.png"] forState:UIControlStateNormal];
        [self.shareButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.shareButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        [self.shareButton setTitle:@"分享" forState:UIControlStateNormal];
        self.shareButton.frame = CGRectMake(140, 5, 60, 30);
        self.shareButton.tag = 1;
        
        
        //收藏按钮
        self.collectionButton = [UIButton buttonWithType: UIButtonTypeCustom];
        [self.collectionButton setBackgroundImage:[UIImage imageNamed:@"btn_popup-data_n@2x.png"] forState:UIControlStateNormal];
        [self.collectionButton setTitle:@"收藏" forState:UIControlStateNormal];
        [self.collectionButton setBackgroundImage:[UIImage imageNamed:@"btn_popup-data_n@2x.png"] forState:UIControlStateNormal];
        [self.collectionButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.collectionButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        self.collectionButton.frame = CGRectMake(215, 5, 60, 30);
        
        self.collectionButton.tag = 2;
        
        //详情按钮
        self.detailButton = [UIButton buttonWithType: UIButtonTypeCustom];
        
        [self.detailButton setTitle:@"详情" forState:UIControlStateNormal];
        
        [self.detailButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.detailButton setBackgroundImage:[UIImage imageNamed:@"btn_popup-data_n@2x.png"] forState:UIControlStateNormal];
        [self.detailButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
        [self.detailButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
        self.detailButton.frame = CGRectMake(290, 5, 60, 30);
        
        self.detailButton.tag = 3;
        [self.contentView addSubview:self.shareButton];
        [self.contentView addSubview:self.collectionButton];
        [self.contentView addSubview:self.detailButton];
        
        
    }
    return self;
}
//点击弹出的cell上的按钮触发的方法
- (void)btnAction:(UIButton *)button
{
    
    if (button.tag == 1) {
        NSLog(@"分享");
    }
    if (button.tag == 2) {
        NSLog(@"收藏");
    }
    
    if (button.tag == 3) {
        NSLog(@"详情");
    }
    
}


- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
